import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Demo6 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = null;
        inputStream = new FileInputStream("./test.txt");
        while(true) {
            //一次读一个
            int b = inputStream.read();
            if (b == -1) {
                //读取完毕
                break;
            }
            System.out.printf("0x%x",b);
            System.out.println();
            //一次全部读取
            byte[] b1 = new byte[1024];
            int n = inputStream.read(b1);
            System.out.println("n="+ n);
            if(n == -1) {
                //此文件读取完毕
                break;
            }
            for (int i = 0; i < n; i++) {
                System.out.printf("0x%x ",b1[i]);
            }
            System.out.println();
        }
    }
}
